// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   FormFactory.java

package include.validator;

import java.util.Enumeration;
import javax.servlet.http.HttpServletRequest;

// Referenced classes of package include.validator:
//			Form, Field

public class FormFactory
{

	public FormFactory()
	{
	}

	public static Form createForm(HttpServletRequest request)
	{
		String formName = request.getParameter("validator.form");
		if (formName != null)
		{
			Form form = new Form();
			form.setName(formName);
			Enumeration names = request.getParameterNames();
			int i = 0;
			while (names.hasMoreElements()) 
			{
				String name = (String)names.nextElement();
				String value[] = request.getParameterValues(name);
				if (!name.equals("validator.form"))
				{
					Field field = new Field();
					field.setName(name);
					field.setValue(value);
					form.addField(field);
				}
			}
			return form;
		} else
		{
			return null;
		}
	}
}
